/**
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2008，所有权利保留。
 * 
 * 项目名：	rumba
 * 文件名：	QCartridgeReader.java
 * 模块说明：	
 * 修改历史：
 * Feb 20, 2008 - lxm - 创建。
 */
package com.hd123.rumba.gwt.cartridge.server.biz;

import com.hd123.rumba.cartridge.biz.BCartridge;
import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.gwt.base.client.exception.ClientBizException;
import com.hd123.rumba.gwt.cartridge.client.biz.QCartridge;
import com.hd123.rumba.util.ObjectUtil;

/**
 * @author lxm
 * 
 */
public class QCartridgeReader {

  public void read(BCartridge source) throws BusinessException {
    ObjectUtil.checkParameterNotNull(source, "source");
    if (target == null)
      throw new BusinessException("属性target不可为null。");
    try {
      target.setUuid(source.getUuid());
      target.setPrefix(source.getPrefix());
      target.setCaption(source.getCaption());
      target.setCaptionEN(source.getCaptionEN());
      target.getVersion().setMacroVersion(source.getVersion().getMacroVersion());
      target.getVersion().setMinorVersion(source.getVersion().getMinorVersion());
      target.getVersion().setRelease(source.getVersion().getRelease());
      target.getVersion().setBuildNo(source.getVersion().getBuildNo());
      target.setRemark(source.getRemark());
      target.setAsCover(source.getAsCover());
      target.setCopyright(source.getCopyright());
      
      target.getResources().clear();
      
//      for(Iterator it = source.getResources().keySet().iterator(); it.hasNext();) {
//    	  String name = (String)it.next();
//    	  String url = source.getResources().get(name).toString();
//    	  target.getResources().put(name, url);
//      }
      Object[] names = source.getResources().keySet().toArray();
      for (Object name: names) {
        String url = source.getResources().get(name);
        target.getResources().put(name, url);
      }
    } catch (ClientBizException e) {
      throw new BusinessException(e);
    }
  }

  private QCartridge target;

  public QCartridge getTarget() {
    return target;
  }

  public void setTarget(QCartridge target) {
    this.target = target;
  }

}
